// Get a files created date and time
// By Ben 00:00:50 24/09/2016

#include <iostream>
#include <Windows.h>
#include <ctime>

using namespace std;
using std::cout;
using std::endl;

SYSTEMTIME GetFileCreateTime(char* Filename){
	string sRetDate = "";
	WIN32_FIND_DATAA fd;
	HANDLE f;
	FILETIME ft;
	SYSTEMTIME st;

	//Get the files handle
	f = FindFirstFileA(Filename, &fd);

	if (f == INVALID_HANDLE_VALUE){
		GetLocalTime(&st);
		return st;
	}
	//Store files ftLastWriteTime into ft
	FileTimeToLocalFileTime(&fd.ftLastWriteTime, &ft);
	//Convert ft to system date time.
	FileTimeToSystemTime(&ft, &st);
	//Close close
	FindClose(f);
	//Return the result.
	return st;
}

int main(int argc, char *argv[]){
	SYSTEMTIME st;
	char *lzFile = "G:\\PRGMMING\\DOS\\BAS_LIBS\\AABAS.ZIP";
	//Fetch file date and time created.

	st = GetFileCreateTime(lzFile);
	
	cout << "Filename    : " << lzFile << endl;
	//Write out the files date and time created.
	cout << "FileDate    : " << st.wDay << "/" << st.wMonth << "/" << st.wYear << endl;
	cout << "FileTime    : " << st.wHour << ":" << st.wMinute << ":" << st.wSecond << endl;
	
	//Keep console open.
	system("pause");
	return 0;
}